//
//  SEDiagnosisCell.swift
//  SmartEyeForDoctor
//
//  Created by QDSG on 2021/4/20.
//

import UIKit

class SEInquiryCell: UITableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()
        backgroundColor = .white
        contentView.backgroundColor = .white
    }
    
    override func setHighlighted(_ highlighted: Bool, animated: Bool) {
        super.setHighlighted(highlighted, animated: animated)
        contentView.backgroundColor = highlighted ? UIColor(hex: "#CCCCCC").withAlphaComponent(0.3) : .white
    }

    func update(with viewModel: SEInquiryViewModel) {
        avatarImageView.kf.setAvatarImage(urlString: viewModel.inquiryDetail.otherPhoto,
                                          placeholder: viewModel.avatarPlaceholder)
        nameLabel.text = viewModel.inquiryDetail.patientName
        ageLabel.text = viewModel.patientAge
        messageLabel.text = viewModel.content
        timeLabel.text = viewModel.dateTime
        sexImageView.image = viewModel.sexImage
        numberLabel.text = viewModel.unReadCount
        numberLabel.isHidden = viewModel.unReadHidden
    }
    
    @IBOutlet private weak var avatarImageView: UIImageView! {
        didSet {
            avatarImageView.layer.cornerRadius = avatarImageView.height / 2
            avatarImageView.layer.masksToBounds = true
        }
    }
    @IBOutlet private weak var nameLabel: UILabel!
    @IBOutlet private weak var ageLabel: UILabel!
    @IBOutlet private weak var messageLabel: UILabel!
    @IBOutlet private weak var timeLabel: UILabel!
    @IBOutlet private weak var numberLabel: UILabel! {
        didSet {
            numberLabel.layer.cornerRadius = numberLabel.height / 2
            numberLabel.layer.masksToBounds = true
        }
    }
    @IBOutlet private weak var sexImageView: UIImageView!
}
